home *** CD-ROM | disk | FTP | other *** search
Wrap
// $Id: RCSControl.FPL 1.11 1995/10/03 14:23:08 jskov Exp $ // $VER: RCSControl.FPL 1.4 (04.10.95) © Jesper Skov $ //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Check Out «« void export RCSCheckOut() { int oldLine = ReadInfo("line"); // Grab cursor position int oldByte = ReadInfo("byte_position"); int success=1; Status(0,"Checking out..."); // Tell user we're working if (System("bin:co -l \""+ReadInfo("full_file_name")+"\"")){ success = 0; if(Request("Check out error!\nProbably the file is already check out!\n(Consult the readme for more help)","RCS request","Force check out!|OK")) if (System("bin:co -l -f \""+ReadInfo("full_file_name")+"\"")){ if(!Request("Check out error again!\nTry to check the file out by hand!\n(Consult the readme for more help)","RCS request","Sigh!|Just change that bloody w-flag, will ya'!")){ SetInfo(-1,"protection",ReadInfo("protection")+"w"); return; } } else success=1; } if (success){ Status(0,"Reloading..."); // Tell user we're working SetInfo(-1,"protection",ReadInfo("protection")+"w"); Load(ReadInfo("full_file_name")); // Reload to get protection bit // and ensure correct contents GotoLine(oldLine, oldByte); // Reposition cursor CenterView(); } } //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Setup comment buffer «« void export EnterRCSComment(int ReLock) { int RevisionID = New(); // Make comment buffer int OrgBuffer = CurrentBuffer(RevisionID); Rename("*RCS Comment*"); // rename it SetInfo(RevisionID, "_IsRCSBuffer", 1); // and fill parent data SetInfo(RevisionID, "_RCSParentBuffer", OrgBuffer); SetInfo(RevisionID, "_RCSReLock", ReLock); ReturnStatus("Press C-c C-c when comment is complete!"); } //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Check In «« void export RCSCheckIn() { int ParentID = ReadInfo("_RCSParentBuffer"); int export thisID = CurrentBuffer(ParentID); int reLock = ReadInfo("_RCSReLock",thisID); string CommentName = "T:RCSComment"+itoa(thisID); // build temp name string ParentName = ReadInfo("full_file_name", ParentID); // get parent name string lock = "-u"; // How the file should be locked if (reLock) // If user wants to reLock, lock = "-l"; // change lock-mode. Save(); // Save parent buffer CurrentBuffer(thisID); // and get back to comment buffer Rename(CommentName); // Rename Save(); // and save comment buffer CurrentBuffer(ParentID); // return control to parent Status(0,"Checking in..."); // Tell user we're working... if (System("bin:ci "+lock+" \""+ParentName+"\" < "+CommentName)) // Check In if(Request("Check in error!\nShould I try to check the file out first?\n(Consult the readme for more help)","RCS request","Yes|No!")) if(System("bin:co -l \""+ParentName+"\"")){ // try to lock file Request("Check out error!\n(Consult the readme for more help)","RCS request","Panic!"); reLock = 1; } else { Save(); // save again (protection bits changed) if (System("bin:ci "+lock+" \""+ParentName+"\" < "+CommentName)){ // retry Check In Request("New attept to check in failed!\n(Consult the readme for more help)","RCS request","Panic!"); reLock = 1; } } else { Request("OK, master. Remember that your changes are not checked in!","RCS request","Panic!"); reLock = 1; } MaximizeView(); // Make parent only view System("delete "+CommentName); // Delete comment file Clean("Kill(thisID);"); // and the comment buffer if (!reLock) // If lock not retained SetInfo(-1,"protectionbits", ReadInfo("protectionbits")|4); // writeprotect parent buffer } //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» ChangeWFlag «« void export ChangeWFlag(int ReLock) { int isRCS; isRCS = Check(ReadInfo("full_file_name")+",v",""); isRCS = isRCS || Check(ReadInfo("file_path")+"RCS/"+ReadInfo("file_name"),""); if ((ReadInfo("protectionbits")&4)){ if (isRCS){ RCSCheckOut(); } else { SetInfo(-1,"protectionbits",ReadInfo("protectionbits")&0xfffb); // if not an RCS file, just alter } // the write protection flag. } else { if (isRCS) EnterRCSComment(ReLock); else { if (Request("Should I put the file under RCS control?","RCS request","Yes|No")){ if (!Check(ReadInfo("file_path")+"RCS")){ // Ask to create RCS dir if (Request("Do you want me to create an RCS directory?","RCS request","Yes|No")){ // Creat RCS dir System("makedir "+ReadInfo("file_path")+"RCS"); } } Request("This first comment will be used for file description.\nDo not enter revision specific information!", "RCS info","Um, OK!"); EnterRCSComment(ReLock); } else { SetInfo(-1,"protectionbits",ReadInfo("protectionbits")|4); // if not an RCS file, just alter } // the write protection flag. } } } //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Make history «« export void RCSMakeHistory() { string file = PromptFile("","Extract history from...","",""); // get file name if (strlen(file)){ string history = file+".history"; if (Check(history)){ switch(Request("History file already exist!","RCS request","Overwrite!|New name|Cancel")){ case 2: // Ask new file name history = PromptFile(history,"Select output file...","","s"); break; case 0: // Cancel operation by setting empty name history=""; break; } } if (strlen(history)){ // Only continue if name defined int prevVisible = Visible(0); // Disable screen update int histID = New(); // Get new buffer System("bin:rlog \""+file+"\" >"+history); // Get history created CurrentBuffer(histID); Load(history); // load history DeleteLine(11); // and make history a bit more readable: SearchSet("=of+","date:"); // Erase difference info while (!Search("date:")){ Search(";"); DeleteEol(); } GotoLine(1); Save(""); // update file to disk Visible(prevVisible); // and update screen RedrawScreen(0); } } } //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Key bindings «« AssignKey("ChangeWFlag(0);","control x control q",""); AssignKey("ChangeWFlag(1);","control x control Q",""); AssignKey("RCSCheckIn();","control c control c", "_IsRCSBuffer"); AssignKey("Clean(\"Kill();\");","control g", "_IsRCSBuffer"); //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Hidden variables «« ConstructInfo("_IsRCSBuffer","","", "LBH", "",0,1,0); ConstructInfo("_RCSReLock","","", "LBH", "",0,1,0); ConstructInfo("_RCSParentBuffer","","", "LIH", "",0,0x7fffffff,0);